package pl.edu.agh.pros.connector;

import pl.edu.agh.pros.conf.XMPPConfiguration;

@SuppressWarnings("nls")
public class MockServerConnector implements IServerConnector {

	private static final String PROVIDER_APP_KEY = "200190f987fc-bf79-4e6e-b603-0e899dfc3a5f";
	private String providerXMPP;
	private String roomName;

	@Override
	public XMPPConfiguration getXMPPConfiguration(String appKey, String devId) {
		return new XMPPConfiguration("localhost", 5222, "conference.ubuntu");
	}

	@Override
	public Long register(String appKey, String devId, String xmppAddress) {
		if (appKey.equals(PROVIDER_APP_KEY)) {
			this.providerXMPP = xmppAddress;
		}
		return 60000L;
	}

	@Override
	public Long registerTopic(String providerAppKey, String topicName, String roomName) {
		if (PROVIDER_APP_KEY.equals(providerAppKey)) {
			this.roomName = roomName;
		}
		return 60000L;
	}

	@Override
	public void unregisterTopic(String providerAppKey, String topicName) {
		// TODO Auto-generated method stub

	}

	@Override
	public String getRoomName(String appKey, String topicName) {
		return roomName;
	}

	@Override
	public String getXmppAddress(String appKey, String devId) {
		if (devId == null) {
			return providerXMPP;
		}
		return null;
	}

}
